<?php
/**************************************************************************************************
|
| AudioShare - Audio Sharing Script
| http://www.audiosharescript.com
| webmaster@audiosharescript.com
| Version: 2.0
|
|**************************************************************************************************
|
| By using this software you agree that you have read and acknowledged our End-User License 
| Agreement available at http://www.audiosharescript.com/eula.html and to be bound by it.
|
| Copyright (c) 2009 AudioShareScript.com. All rights reserved.
|**************************************************************************************************/

include("../include/config.php");
include_once("../include/functions/import.php");
include_once("../include/functions/admin.php");
verify_login_admin();

$MID = intval($_REQUEST['MID']);

if($_POST['submitform'] == "1")
{
	if($MID > 0)
	{
		$arr = array("subject", "message");
		foreach ($arr as $value)
		{
			$sql = "update messages_inbox set $value='".mysql_real_escape_string($_POST[$value])."' where MID='".mysql_real_escape_string($MID)."'";
			$conn->execute($sql);
			$sql = "update messages_sent set $value='".mysql_real_escape_string($_POST[$value])."' where MID='".mysql_real_escape_string($MID)."'";
			$conn->execute($sql);
		}

		$message = "Message Successfully Edited.";
		Stemplate::assign('message',$message);
	}
}

if($MID > 0)
{
	$query = $conn->execute("select A.*,B.username as tousername, C.username as fromusername from messages_inbox A, members B, members C where MID='".mysql_real_escape_string($MID)."' AND A.MSGTO=B.USERID AND A.MSGFROM=C.USERID limit 1");
	$msg = $query->getrows();
	Stemplate::assign('msg', $msg[0]);
}

$mainmenu = "10";
$submenu = "1";
Stemplate::assign('mainmenu',$mainmenu);
Stemplate::assign('submenu',$submenu);
STemplate::display("administrator/global_header.tpl");
STemplate::display("administrator/messages_edit.tpl");
STemplate::display("administrator/global_footer.tpl");
?>